#!/bin/bash

set -e

if [[ -n $1 ]]; then
  echo "A script that will record videos of all booted Simulators"
  echo "When you have finished recording, send a SIGTERM with Ctrl-C"
  echo "The locations of the video files will be written to stderr, before the script terminates"
  echo "This command should be provided with no arguments"
  exit 1
fi

echo "Starting Recording: When you have finished recording press Ctrl-C" 1>&2
fbsimctl --debug-logging --simulators --state=booted record start 1>&2
fbsimctl --simulators --state=booted diagnose | grep video | awk '{print $NF}'
